9B - Running Student - CodeForces Solution


brute force geometry implementation *1200

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define all(s) s.begin(),s.end()

const double pi = acos(-1);
typedef long long ll;
typedef unsigned long long ull;

int main()

{
    SR();

         double n , b , s;
         cin >> n >> b >> s;
         vector<double> aa(n) , bb(n);
         bb[0] = 100000000;
         for(int i = 0 ; i < n ; i++)
         cin >> aa[i];
         ll x , y;
         cin >> x >> y;
         double mn  = 1e10;
         ll lol = 1000000000;

         for(int i = 1 ; i < n ; i++)
         {
            bb[i] = aa[i] / b + ((double)sqrt((x - (ll)aa[i]) * (x - (ll)aa[i]) + (y) * (y))) / s;
            mn = min(mn , bb[i]);
            if(mn == bb[i])
            lol = i + 1;
         }
         cout << lol << endl;
        //  for(auto u : bb)
        //  cout << u << endl;

        //  cout << endl;
        //  cout << mn << endl;
        // ll ans = x;
        // ll ii;
        // for(int i = 1 ; i < n ; i ++)
        // {
        //     if(bb[i] == mn)
        //     {
        //         if(abs(x - (i + 1)) < ans)
        //         {
        //             ans = abs(x - (i + 1));
        //             ii = i + 1;
        //         }
        //     }
        // }
        // if(x == 0)
        // cout << "2" << endl;
        // else 
        // cout << ii << endl;
         

    return 0;
}


Comments

Submit
0 Comments
More Questions

145. Binary Tree Postorder Traversal
94. Binary Tree Inorder Traversal
101. Symmetric Tree
77. Combinations
46. Permutations
226. Invert Binary Tree
112. Path Sum
1556A - A Variety of Operations
136. Single Number
169. Majority Element
119. Pascal's Triangle II
409. Longest Palindrome
1574A - Regular Bracket Sequences
1574B - Combinatorics Homework
1567A - Domino Disaster
1593A - Elections
1607A - Linear Keyboard
EQUALCOIN Equal Coins
XOREQN Xor Equation
MAKEPAL Weird Palindrome Making
HILLSEQ Hill Sequence
MAXBRIDGE Maximise the bridges
WLDRPL Wildcard Replacement
1221. Split a String in Balanced Strings
1002. Find Common Characters
1602A - Two Subsequences
1555A - PizzaForces
1607B - Odd Grasshopper
1084A - The Fair Nut and Elevator
1440B - Sum of Medians